package com.aispeech.asr.apis.detection.domain;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.aispeech.asr.apis.detection.form.DetectionForm;

import lombok.Getter;
import lombok.Setter;

public class EventDetectionContext {
    @Getter
    private String sessionId;

    @Getter
    private DetectionForm form;

    @Getter
    private InputStream stream;

    private Map<String, Long> metrics;

//    @Getter
//    @Setter
//    private AsrResult[] asrResults;

    @Getter
    @Setter
    private String res;
    
    @Getter
    @Setter
    private EventDetectionResult result;
    
    @Getter
    @Setter
    private List<EventDetection> resultList;

    public static EventDetectionContext of(String sessionId, DetectionForm form, InputStream stream) {
        EventDetectionContext context = new EventDetectionContext();

        context.sessionId = sessionId;
        context.form = form;
        context.stream = stream;

        context.metrics = new HashMap<String, Long>() {{
            put("received", System.currentTimeMillis());
        }};

        return context;
    }

    public void addMetric(String metric) {
        if (form != null && metrics != null) {
            metrics.put(metric, System.currentTimeMillis());
        }
    }

    public Map<String, Long> getMetrics() {
        return metrics;
    }
}
